package com.baida.retail.tasksystem.controller;

import com.baida.retail.tasksystem.entity.Order;
import com.baida.retail.tasksystem.message.logic.Result;
import com.baida.retail.tasksystem.message.logic.order.OrderRequest;
import com.baida.retail.tasksystem.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("order")
@Api(value = "订单操作模块", tags = "订单模块")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PostMapping("/getOrderById")
    @ApiOperation(
            value = "查找对应的订单信息",
            notes = "通过订单id获取订单的详细信息")
    @ApiResponses(
            @ApiResponse(code = 200, message = "操作成功", response = Order.class)
    )
    public Result getOrderById(@RequestBody OrderRequest orderRequest) {
        log.info("getOrderById {}", orderRequest);

        return orderService.getOrderById(orderRequest.getOrderId());
    }
}
